<?php
/**
 * Morningtime LatestReviews extension
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/osl-3.0.php
 *
 * @category   Morningtime
 * @package    Morningtime_LatestReviews
 * @copyright  Copyright (c) 2009 Morningtime Internet, http://www.morningtime.com
 * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */
?>
<?php 
$_items 	= $this->getReviewsCollection();
$listFields = Mage::getStoreConfig('latestreviews/reviews/show_fields');
?>
<?php if (count($_items) && !empty($listFields)):?>
	<table class="data-table" id="latest-reviews-table" cellspacing="0">
		<tbody>
			<?php while ($_review = $_items->fetch()): ?>
			<?php $_product = Mage::getModel('catalog/product')->load($_review['entity_pk_value']); ?>
			<tr>
				<?php if (preg_match("/date/", $listFields)): ?>
				<td><?php echo $this->dateFormat($_review['created_at']) ?></td>
				<?php endif; ?>
				<?php if (preg_match("/title/", $listFields)): ?>
				<td><a href="<?php echo $this->getProductLink($_product, $_review) ?>"><?php echo $this->getTitle($_product, $_review) ?></a></td>
				<?php endif; ?>
				<?php if (preg_match("/preview/", $listFields)): ?>
				<td><?php echo $this->htmlEscape($this->helper('review')->getDetail($_review['detail'])) ?></td>
				<?php endif; ?>
				<?php if (preg_match("/rating/", $listFields)): ?>
				<td>
					<div class="rating-box">
						<div class="rating" style="width: <?php echo $_review['rating_summary'] ?>%;"></div>
					</div>
				</td>
				<?php endif; ?>
			</tr>

        <?php endwhile; ?>
		</tbody>
	</table>
	<script type="text/javascript">decorateTable('latest-reviews-table')</script>
<?php endif; ?>
